package com.literaryfamily.literaryfamily.enumPackage;

import com.literaryfamily.literaryfamily.exceptions.OperationException;

public enum RolesType {
	TOURISTS(0, "游客"),
	USER(1, "一般用户"),
	OPERATORS(2, "运营商"),
	ROOT(114514, "管理员"),
	;

	public int getLevel() {
		return level;
	}

	public String getRolesName() {
		return rolesName;
	}

	RolesType(int level, String rolesName) {
		this.level = level;
		this.rolesName = rolesName;
	}

	private final int level;
	private final String rolesName;

	public static RolesType getNeedRolesLevel(int staticNum) {
		if (staticNum <= TOURISTS.level) return TOURISTS;
		if (staticNum <= USER.level) return USER;
		if (staticNum <= OPERATORS.level) return OPERATORS;
		if (staticNum <= ROOT.level) return ROOT;
		throw new OperationException("错误!需要的权限高于root!");
	}

}